/**
* Created by wust on 2020-07-15 14:16:52.
*/
<template>
	<el-form ref="formModel" :model="formModel" :rules="rules" label-width="120px" style="width:70%;"
	 @submit.native.prevent>
		<el-form-item label="order_id" prop="orderId">
			<el-input v-model="formModel.orderId"></el-input>
		</el-form-item>
		<el-form-item label="order_no" prop="orderNo">
			<el-input v-model="formModel.orderNo"></el-input>
		</el-form-item>
		<el-form-item label="quantity" prop="quantity">
			<el-input v-model="formModel.quantity"></el-input>
		</el-form-item>
		<el-form-item label="goods_id" prop="goodsId">
			<el-input v-model="formModel.goodsId"></el-input>
		</el-form-item>
		<el-form-item label="goods_name" prop="goodsName">
			<el-input v-model="formModel.goodsName"></el-input>
		</el-form-item>
		<el-form-item label="goods_price" prop="goodsPrice">
			<el-input v-model="formModel.goodsPrice"></el-input>
		</el-form-item>
		<el-form-item label="goods_picture" prop="goodsPicture">
			<el-input v-model="formModel.goodsPicture"></el-input>
		</el-form-item>
		<el-form-item label="total_amount" prop="totalAmount">
			<el-input v-model="formModel.totalAmount"></el-input>
		</el-form-item>
		<el-form-item label="description" prop="description">
			<el-input v-model="formModel.description"></el-input>
		</el-form-item>
		<el-form-item label="is_deleted" prop="isDeleted">
			<el-input v-model="formModel.isDeleted"></el-input>
		</el-form-item>

		<el-form-item style="text-align: left;">
			<el-button type="primary" @click="onSubmit('formModel')" :loading="submitting">提交</el-button>
		</el-form-item>
	</el-form>
</template>
<script>
import Vue from 'vue'

export default {
  name: 'detail-create',
  data () {
    return {
      submitting: false,
      formModel: {
        orderId: null,
        orderNo: null,
        quantity: null,
        goodsId: null,
        goodsName: null,
        goodsPrice: null,
        goodsPicture: null,
        totalAmount: null,
        description: null,
        isDeleted: null

      },
      rules: {}
    }
  },
  methods: {
    onSubmit: function (formData) {
      this.$refs[formData].validate((valid) => {
        if (!valid) {} else {
          this.submitting = true
          Vue.$ajax({
            method: 'post',
            url: Vue.$orderServerURL + '/web/v1/DetailController',
            data: this.formModel
          }).then(res => {
            this.submitting = false
            if (res.data.flag !== 'SUCCESS') {
              if (!Vue.$isNullOrIsBlankOrIsUndefined(res.data.message)) {
                this.$message({
                  message: res.data.message,
                  type: 'warning'
                })
              }
            } else {
              this.$message({
                message: res.data.message,
                type: 'success'
              })
              this.resetForm('formModel')
            }
          })
        }
      })
    },
    resetForm (formData) {
      this.$refs[formData].resetFields()
    }
  }
}
</script>
